package it.blueocean.acanto.taglibrary.jsp.taglib.tags.navigation;

import java.io.IOException;
import java.util.Iterator;
import java.util.List;

import javax.servlet.jsp.JspWriter;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import it.blueocean.acanto.entities.platform.MenuItem;
import it.blueocean.acanto.taglibrary.jsp.taglib.navigation.NavigationTag;

public class SimpleMenuTag extends NavigationTag
{
	private static final long serialVersionUID = -3204927301435089709L;

	private final static Logger logger = LoggerFactory.getLogger(SimpleMenuTag.class);

	protected void createHTML(MenuItem paramMenuItem, JspWriter paramJspWriter) throws IOException
	{
		int i = 0;
		List<MenuItem> localList = paramMenuItem.getChildren();
		paramJspWriter.write("<ul>");
		Iterator<MenuItem> localIterator = localList.iterator();
		while (localIterator.hasNext())
		{
			MenuItem localMenuItem = localIterator.next();
			paramJspWriter.write("<li class=\"" + ((0 == i++) ? "first" : "") + " "
					+ ((localMenuItem.isSelected()) ? "sel" : "") + "\">");
			paramJspWriter.write(getHref(localMenuItem.getId(), localMenuItem.getTitle()));
			paramJspWriter.write("</li>");
		}
		paramJspWriter.write("</ul>");
	}
}